/**
 * File: ConsoleTester.java
 * Project: CMSC 345 - VirtualAdvisor
 * @author Wallace Brown
 * Date: April 28, 2011
 * E-mail: brownw1@umbc.edu 
 * Description: The class for testing the application
 * 		via console.
 */

package virtualadvisor;

import java.util.ArrayList;
import java.util.LinkedList;

public class ConsoleTester {
	
	public void TestClass_Student(){
		//Create two cases.
		Student s1 = new Student("Jim",null,"Bio");
		
		ArrayList<String> majors  = new ArrayList<String>();
		majors.add("Math");
		majors.add("Philosophy");
		
		Student s2 = new Student("Paula",majors,"Psychology");

		//Obtain our data.
		String s1_majors = "";
		for(String s : s1.getMajor()){s1_majors += s;}
		String s1_output = "Student 1:\n\tname: " + s1.getName() +
			"\n\tmajors: " + s1.getMajor() +
			"\n\tminors: " + s1.getMinor();

		String s2_majors = "";
		for(String s : s2.getMajor()){s2_majors += s;}
		String s2_output = "Student 2:\n\tname: " + s2.getName() +
			"\n\tmajors: " + s2.getMajor() +
			"\n\tminors: " + s2.getMinor();

		//Display.
		System.out.println(s1_output);
		System.out.println(s2_output);
	}

	public void TestClass_Course(){
		//Create several cases.
		//With no reqs.
		Course c1 = new Course("Art in America", "Art",101,"Art in America","American Art in the 1900's to now.",
				'F',4,null,false,null);

		Course c2 = new Course("Math0", "Math",100,"Intro to Math","Basic College Math.",
				'B',3,null,true,null);
		Course c3 = new Course("Physics0", "Physics",100,"Intro to Physics","Basic College Physics.",
				'A',4,null,false,null);
		
		ArrayList<String> pre_reqs = new ArrayList<String>();
		pre_reqs.add("SomeReq"); pre_reqs.add("SomeOtherReq");
		
		//With several reqs.
		Course c4 = new Course("Physics0", "Physics",101,"College Physics","Intro 2 to Physics.",
				'B',3,pre_reqs,false,new ArrayList<String>());
		

		Course c5 = new Course("PhysEd", "PhysEd",100,"Physical Education","Physical Education",
				'A',3,null,true,null);
		Course c6 = new Course("European History", "History",100,"History of Europe","History of Europe 1700-1900",
				'C',3,null,true,null);

		ArrayList<String> gre_reqs = new ArrayList<String>();
		gre_reqs.add("European History"); gre_reqs.add("PhysEd");

		//With several more reqs.
		Course c7 = new Course("SomeCourse", "SomeDepartment",101,"SomeCourse","Some Description.",
				'D',3,pre_reqs,true,gre_reqs);
		
		//Output our data.
		System.out.println(c1.toString());
		System.out.println(c5.toString());
		System.out.println(c7.toString());
	}
	
	public void TestClass_Semester(){
		//Create several cases.
		Semester s1 = new Semester("Fall",2011);
		Semester s2 = new Semester("Summer",2012);
		
		Course c1 = new Course("Math0", "Math",100,"Intro to Math","Basic College Math.",
				'B',3,null,true,null);
		Course c2 = new Course("Physics0", "Physics",100,"Intro to Physics","Basic College Physics.",
				'A',4,null,false,null);
		s2.addCourse(c1);	s2.addCourse(c2);
		
		//Gather our data.
		String s1_output = "";
		String s1_courses="";
		if(s1_courses != null)
			for(Course c : s1.getCourses()){s1_courses += c.getName() + "|";}
		s1_output += "semester 1:\n\tseason:" + s1.getSeason() +
			"\n\tyear: " + s1.getYear()+
			"\n\tcourses: " + s1_courses;

		String s2_output = "";
		String s2_courses="";
		if(s2_courses != null)
			for(Course c : s2.getCourses()){s2_courses += c.getName() + "|";}
		s2_output += "semester 2:\n\tseason:" + s2.getSeason() +
			"\n\tyear: " + s2.getYear()+
			"\n\tcourses: " + s2_courses;
		
		//Output our data.
		System.out.println(s1_output);
		System.out.println(s2_output);
		
		//Test our comparison
		int result = s1.compareTo(s2);
		if( result == 0){System.out.println("semester 1 and 2 are the same.");}
		else if( result == -1){System.out.println("semester 1 is earlier than semester 2.");}
		else if( result == 1){System.out.println("semester 1 is later than semester 2.");}
	}

	public void TestClass_DegreeProgress(){
		//Create several cases.
		Course c1 = new Course("Math0", "Math",100,"Intro to Math","Basic College Math.",
				'B',3,null,true,null);
		Course c2 = new Course("Physics0", "Physics",100,"Intro to Physics","Basic College Physics.",
				'A',4,null,false,null);
		Course c3 = new Course("PhysEd", "PhysEd",100,"Physical Education","Physical Education",
				'A',3,null,true,null);
		
		LinkedList<Course> reqs1 = new LinkedList<Course>();
		reqs1.add(c1);	reqs1.add(c2);
		
		LinkedList<String> grestuff = new LinkedList<String>();
		grestuff.add("PhysEd");	grestuff.add("Skiing");

		DegreeProgress dp1 = new DegreeProgress(reqs1, grestuff);
		DegreeProgress dp2 = new DegreeProgress(null, grestuff);
		
		dp1.addCompleteCourse(c1);	dp1.addCompleteCourse(c3);
		
		//Gather our data.
		String dp1_output = "degreeProgress 1:\n\tremaining courses: ";
		for(Course c : dp1.getRemainingCourses())
			if(c!=null){dp1_output += c.getTitle()+" ,";}

		dp1_output += "\n\tcompleted courses: ";
		for(Course c : dp1.getCompletedCourses())
			if(c!=null){dp1_output += c.getTitle()+" ,";}
		
		//Output our results.
		System.out.println(dp1_output);
	}
	
	public void TestClass_Plan(){
		//Create our test cases.
		Plan p1 = new Plan();
		Plan p2 = new Plan("SomeName");
		
		//check for sorted construction.
		ArrayList<Semester> s1 = new ArrayList<Semester>();
		s1.add(new Semester("spring",2013));
		s1.add(new Semester("fall",2012));
		Plan p3 = new Plan(s1,"SomeOtherName");
		
		Plan p4 = new Plan("SomeOtherOtherName");

		//check for adding semesters and their sorting.
		p1.addSemester(new Semester("winter",2012));
		p1.addSemester(new Semester("winter",2011));
		p1.addSemester(new Semester("spring",2011));

		//check for catching duplicates.
		p2.addSemester(new Semester("winter",2012));
		p2.addSemester(new Semester("winter",2011));
		p2.addSemester(new Semester("spring",2011));
		p2.addSemester(new Semester("winter",2012));
		p2.addSemester(new Semester("winter",2011));
		p2.addSemester(new Semester("spring",2011));
		
		//check for deleting.
		p4.addSemester(new Semester("winter",2012));
		p4.addSemester(new Semester("winter",2011));
		p4.addSemester(new Semester("spring",2011));
		p4.deleteSemester(new Semester("winter",2012));
		p4.deleteSemester(new Semester("spring",2011));
		
		//check get semester.
		Semester stmp1 = p1.getSemester("winter", 2012);
		Semester stmp2 = p1.getSemester("iDontExist", 2020);
		
		//Collect our data.
		String s1Output = "";
		s1Output += "S1 semesters: ";
		for(Semester s : p1.getList()){s1Output += s.toString() + "\n";}

		String s2Output = "";
		s2Output += "S2 semesters: ";
		for(Semester s : p2.getList()){s2Output += s.toString() + "\n";}

		String s3Output = "";
		s3Output += "S3 semesters: ";
		for(Semester s : p3.getList()){s3Output += s.toString() + "\n";}

		String s4Output = "";
		s3Output += "S4 semesters: ";
		for(Semester s : p4.getList()){s4Output += s.toString() + "\n";}

		String s5Output = "";
		s5Output += "S5 getSemester check: ";
		s5Output += stmp1 + "\n" + stmp2 + "\n";
		
		//Show our data.
		//System.out.println(s1Output);
		//System.out.println(s2Output);
		//System.out.println(s3Output);
		//System.out.println(s4Output);
		System.out.println(s5Output);
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ConsoleTester ct = new ConsoleTester();
		
		//ct.TestClass_Student();
		//ct.TestClass_Course();
		//ct.TestClass_Semester();
		//ct.TestClass_DegreeProgress();
		ct.TestClass_Plan();
	}

}
